package v1

import (
	"gin-vben-admin/internal/constant"
	"gin-vben-admin/pkg/db"
)

type SysRoleCreateReq struct {
	AuthId int64 `json:"-" binding:"required"` //创建者

	RoleName string          `form:"role_name" json:"role_name" binding:"required,min=1,max=30" comment:"角色名称" msg:"用户名格式错误"` //角色名称
	Sort     int             `form:"sort" json:"sort" binding:"omitempty" comment:"排序"`                                       //显示排序
	Status   constant.Status `form:"status" json:"status" binding:"required,oneof=1 2" comment:"状态"`                          //状态 1启用 2禁用
	Remark   string          `form:"remark" json:"remark" binding:"omitempty,max=128" comment:"备注"`                           //备注
	MenuIds  []int64         `form:"menu_ids"  json:"menu_ids"  binding:"omitempty,dive,gt=0" comment:"绑定菜单权限"`               //绑定菜单权限的id
}

type SysRoleListReq struct {
	Kw     string          `form:"kw" json:"kw" binding:"omitempty" `                                                                   //角色名称
	Status constant.Status `form:"status" json:"status" binding:"omitempty,oneof=1 2" search:"table:sys_role;column:status;type:exact"` //状态
	db.Paginator
}

type SysRoleUpdateReq struct {
	AuthId int64 `json:"-" binding:"required"` //创建者

	RoleId   int64           `form:"role_id" json:"role_id" binding:"required"`
	RoleName string          `form:"role_name" json:"role_name" binding:"required,min=1,max=30" comment:"角色名称" msg:"用户名格式错误"` //角色名称
	Sort     int             `form:"sort" json:"sort" binding:"omitempty" comment:"排序"`                                       //显示排序
	Status   constant.Status `form:"status" json:"status" binding:"required,oneof=1 2" comment:"状态"`                          //状态 1启用 2禁用
	Remark   string          `form:"remark" json:"remark" binding:"omitempty,max=128" comment:"备注"`                           //备注
	MenuIds  []int64         `form:"menu_ids"  json:"menu_ids"  binding:"omitempty,dive,gt=0" comment:"绑定菜单权限"`               //绑定菜单权限的id
}

//
//func (c *RoleCreateReq) Generate(ctx http.Context) *models.SysRole {
//	model := &models.SysRole{}
//	model.RoleName = c.RoleName
//	model.Sort = c.Sort
//	model.Status = c.Status
//	model.Remark = c.Remark
//	authId := token.AuthId(ctx)
//	model.CreateBy = authId
//	model.UpdateBy = authId
//	return model
//}
//
//func (c *RoleUpdateReq) Generate(model *models.SysRole, ctx http.Context) *models.SysRole {
//	model.RoleName = c.RoleName
//	model.Sort = c.Sort
//	model.Status = c.Status
//	model.Remark = c.Remark
//	authId := token.AuthId(ctx)
//	model.UpdateBy = authId
//	return model
//}
